﻿using AllanXingCommonLibrary;
using NotificationsExtensions.TileContent;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Notifications;

namespace BackgroundAgant
{
    class TileHelper
    {
        public static bool EnableNotificationQueue
        {
            set
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(value);
            }
        }
        public static void AddTile( List<ArticleInfo> artList)
        {
            ITileWideText09 tilewindeText03 = TileContentFactory.CreateTileWideText09();
            for (int i = 0; i < 3; i++)
            {
                ArticleInfo art = (artList[i] as ArticleInfo);
                tilewindeText03.TextHeading.Text = art.Title;
                tilewindeText03.TextBodyWrap.Text = art.Overview;
                ITileSquareText04 squareContent = TileContentFactory.CreateTileSquareText04();
                squareContent.TextBodyWrap.Text = art.Title;
                tilewindeText03.SquareContent = squareContent;
                TileNotification tn = tilewindeText03.CreateNotification();
               
                if (art.Title.Length > 5)
                {
                    tn.Tag = (artList[i] as ArticleInfo).Title.Substring(0, 5);
                }
                else
                    tn.Tag = (artList[i] as ArticleInfo).Title;

                TileUpdateManager.CreateTileUpdaterForApplication().Update(tn);
            }
        }
    }
}
